package cn.wolfcode.shop.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;

import cn.wolfcode.shop.domain.PropertyValue;
import cn.wolfcode.shop.service.IPropertyValueService;
import cn.wolfcode.shop.vo.JSONResult;

@Controller
@RequestMapping("/propertyValues")
public class PropertyValueController {

	@Reference
	private IPropertyValueService propertyValueService;

	/**
	 * 新增或者修改商品属性值
	 * @param propertyValuesList
	 * @return
	 */
	@PostMapping
	@ResponseBody
	public JSONResult saveOrUpdate(@RequestBody List<PropertyValue> propertyValuesList) {
		propertyValueService.saveOrUpdate(propertyValuesList);
		return new JSONResult();
	}

	@DeleteMapping("/{id}")
	@ResponseBody
	public JSONResult delete(@PathVariable Long id) {
		propertyValueService.delete(id);
		return new JSONResult();
	}
}
